package com.producteev.version0.test;

import com.producteev4j.exceptions.ProducteevException;
import com.producteev4j.model.response.Label;
import com.producteev4j.model.response.UserLogin;
import com.producteev4j.services.ProducteevService;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by IntelliJ IDEA.
 * User: jcarrey
 * Date: 14/05/11
 * TimeImpl: 17:07
 * To change this template use File | Settings | File Templates.
 */
public class ITTestLabelsProducteevServices extends TestCase {

    private static ProducteevService service;

    @Before
    public void setUp() {
        if (service == null) {
            ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext-test.xml");
            service = (ProducteevService) applicationContext.getBean("service");
        }
    }


    private static final String EMAIL = "juankarrey@gmail.com";
    private static final String PASSWORD = "pr0duc733v4j";

    private static final long ID_DASHBOARD = 146402;
    private static final long LABEL_ID = 356866L;

    private static String userToken;
    private static Label label;


    @Test
    public void testUserLogin() throws ProducteevException {
        UserLogin userLogin = service.userLogin(EMAIL, PASSWORD);
        userToken = userLogin.getToken();
    }


    @Test
    public void testCreateLabel() throws ProducteevException {
        label = service.createLabel(userToken, ID_DASHBOARD, "NuevoLabelSuperUtil");
    }

    @Test
    public void testsetTitleLabel() throws ProducteevException {
        service.setLabelTitle(userToken, label.getIdLabel(), "Otro titulo distinto");
    }

    @Test
    public void testGetLabels() throws ProducteevException {
        service.getLabels(userToken, ID_DASHBOARD, null, 1);

    }

    @Test
    public void testGetTasksWithLabel() throws ProducteevException {
        service.getTasksWithLabel(userToken, LABEL_ID, 1);
    }

    @Test
    public void testGetLabel() throws ProducteevException {
        service.getLabel(userToken, LABEL_ID);
    }

    @Test
    public void testDeleteLabel() throws ProducteevException {
        service.deleteLabel(userToken, label.getIdLabel());
    }


}
